<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    function theCityThatAlwaysSleeps() {
        let getCity;

        if (true) {
            let city = "Seattle";
            getCity = function () {
                console.log(city);
                // return city;
            }
        }
        return getCity();
    }
    theCityThatAlwaysSleeps();

    function f() {
        let a = 100;

        let ff = function () {
            // Still okay to reference 'a'
            let b = a + 1;
            console.log(b);
            return b;
        }

        // Error: 'b' doesn't exist here
        return ff();
    }
    f();


    // ({ a, b } = { a: "baz", b: 101 });
    // console.log(a, b);

    let o = {
        a: "foo",
        b: 12,
        c: "bar"
    };
    let { a, ...passthrough } = o;
    let total = passthrough.b + passthrough.c.length;
    console.log(total);

    let defaults = { food: "spicy", price: "$$", ambiance: "noisy" };
    let search = { food: "rich", ...defaults };
    console.log(search);

    function test() {
        console.log('1: ', a) //undefined
        if (false) {
            var a = 1
        }
        console.log('3: ', a) //undefined
    }
    test()


</script>

</html>